home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
internet
/
miami_dodatki
/
savetime
/
savetime.miami
next >
Wrap
Text File
|
1997-04-06
|
3KB
|
116 lines
/*
$VER: savetime.miami 1.1 (04 Apr 1997)
savetime.miami for Miami 1.1 or better
© Georges Heinesch <geohei@ibm.net>
Saves the ntp updated system time to the battery-powered real-time
clock. Optionally creates a log file showing the difference between the
system time and ntp time.
See savetime.readme for details.
*/
/*
Varibles
'log' - logging desired or not; 'true' or 'false'
'logfile' - if 'log' variable is set to 'true', enter the filename here
(including the path from PROGDIR:)
'secdelta' - fix value for correction purpose, depending on system speed
*/
log = 'true'
logfile = 'Miami_Time.log'
secdelta = 1
/* body */
options results
/* if log not desired, save ntp time and exit */
if log ~= 'true' then
do
address command 'C:SetClock SAVE'
exit
end
/* get ntp time */
address command 'C:Date >T:Date'
if open( date,'T:Date',r ) then
do
datentp = readln( date )
call close( date )
end
else
say 'Could not open "T:Date" !!!'
timentp = right( datentp,8 )
/* get old system time */
address command 'C:SetClock LOAD >T:Date'
address command 'C:Date >T:Date'
if open( date,'T:Date',r ) then
do
dateold = readln( date )
call close( date )
end
else
say 'Could not open "T:Date" !!!'
timeold = right( dateold,8 )
address command 'C:Delete >NIL T:Date'
/* save ntp time */
address command 'C:Date' timentp
address command 'C:SetClock SAVE'
/* compare both times and log */
secntp = left( timentp,2 ) * 3600 + substr( timentp,4,2 ) *60 + right( timentp,2 )
secold = left( timeold,2 ) * 3600 + substr( timeold,4,2 ) *60 + right( timeold,2 )
secerror = secntp - secold - secdelta
if ( secerror > 0 ) then timeerror = '+'
if ( secerror < 0 ) then timeerror = '-'
if ( secerror = 0 ) then timeerror = ' '
secerror = abs( secerror )
hh = right( '0' || trunc( secerror / 3600 ),2 )
mm = right( '0' || trunc( ( secerror - hh * 3600 ) / 60 ),2 )
ss = right( '0' || secerror - hh * 3600 - mm * 60,2 )
timeerror = timeerror || hh || ':' || mm || ':' || ss
error = word( datentp,2,1 ) || ' ' || timeold || ' ' || timentp || ' ' || timeerror
if ~open( log,logfile,r ) then
do
call open( log,logfile,w ) then
writeln( log,'Date old time ntp time error' )
writeln( log,'--------- -------- -------- ---------' )
end
call close( log )
if open( log,logfile,a ) then
do
writeln( log,error )
call close( log )
end
else
say 'Could not open "' || logfile || '" !!!'
/* the end */
exit